#!/usr/bin/env ruby

LKP_SRC = ENV['LKP_SRC'] || File.dirname(File.dirname(File.realpath($PROGRAM_NAME)))

require "#{LKP_SRC}/lib/log"
require "#{LKP_SRC}/lib/string_ext"

nr = 0

$stdin.each_line do |line|
  line = line.resolve_invalid_bytes

  case line
  when /^time:/
    puts line
  when /^node:/
    _node, nr = line.split
  when /^ (\d+)$/
    puts "node#{nr}: #{$1}"
  else
    key, value = line.split
    puts "node#{nr}.#{key}: #{value}"
  end
end
